/*
 *  FILE   : queue.h
 *  AUTHOR : Jeffrey Hunter
 *  WEB    : http://www.iDevelopment.info
 *  NOTES  : Define queue record structure and
 *           all forward declarations.
 *
 *  Obtained from: http://www.idevelopment.info/data/Programming/data_structures/c/Queue/Queue.shtml
 *  Edited by: Nicholas Swartzendruber
 */

#include <stdio.h>
#include <stdlib.h>

#define Error(Str)        FatalError(Str)
#define FatalError(Str)   fprintf(stderr, "%s\n", Str), exit(1)

#define ELEMENT_TYPE void*

/*****************************************
 * Define everything related to the queue.
 *****************************************/
#ifndef _Queue_h

  struct QueueRecord;
  typedef struct QueueRecord *Queue;

  int          queue_IsEmpty(Queue Q);
  int          queue_IsFull(Queue Q);
  Queue        queue_CreateQueue(int MaxElements);
  void         queue_DisposeQueue(Queue Q);
  void         queue_MakeEmpty(Queue Q);
  void         queue_Enqueue(ELEMENT_TYPE X, Queue Q);
  ELEMENT_TYPE queue_Front(Queue Q);
  void         queue_Dequeue(Queue Q);
  ELEMENT_TYPE queue_FrontAndDequeue(Queue Q);

#endif  /* _Queue_h */

#define MinQueueSize (1)

/*****************************************
* Define the queue struct
*****************************************/
struct QueueRecord {
  int Capacity;
  int Front;
  int Rear;
  int Size;
  ELEMENT_TYPE *Array;
};
